home *** CD-ROM | disk | FTP | other *** search
/ Czech Logic, Card & Gambling Games / Logické hry.iso / hry / Fish Fillets / script / alibaba / code.lua next >
Text File  |  2005-07-16  |  10KB  |  322 lines

  1.  
  2. -- -----------------------------------------------------------------
  3. -- Init
  4. -- -----------------------------------------------------------------
  5. local function prog_init()
  6.     initModels()
  7.     sound_playMusic("music/rybky07.ogg")
  8.     local pokus = getRestartCount()
  9.     local roompole = createArray(2)
  10.  
  11.  
  12.     -- -------------------------------------------------------------
  13.     local function prog_init_room()
  14.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  15.  
  16.         room.cas = random(100) + 10
  17.         room.zakaz = 0
  18.  
  19.         return function()
  20.             pom2 = 99
  21.             if no_dialog() and isReady(small) and isReady(big) then
  22.                 if room.cas > 0 then
  23.                     room.cas = room.cas - 1
  24.                 else
  25.                     room.cas = random(1000) + 600
  26.                     pom1 = roompole[1]
  27.                     if math.mod(pom1, 4) == 2 then
  28.                         if room.zakaz == 1 then
  29.                             pom1 = pom1 + 1
  30.                         end
  31.                     end
  32.                     pom2 = math.mod(pom1, 4)
  33.                     pom1 = pom1 + 1
  34.                     pom1 = math.mod(pom1, 4)
  35.                     roompole[1] = pom1
  36.                 end
  37.             end
  38.             switch(pom2){
  39.                 [0] = function()
  40.                     addm(7, "kni-m-svicny")
  41.                     if pokus < 3 or random(3) > 0 then
  42.                         addv(7, "kni-v-ber")
  43.                     end
  44.                 end,
  45.                 [1] = function()
  46.                     addv(7, "kni-v-prolezt")
  47.                     addm(7, "kni-m-tloustka")
  48.                     addv(7, "kni-v-padavko")
  49.                     addm(7, "kni-m-hromado")
  50.                     adddel(7)
  51.                     planBusy(big, true)
  52.                     addv(1, "kni-v-vypni")
  53.                     planBusy(big, false)
  54.                 end,
  55.                 [2] = function()
  56.                     addm(7, "kni-m-hrncirstvi")
  57.                     addv(7, "kni-v-amforstvi")
  58.                     addm(7, "kni-m-amfornictvi")
  59.                 end,
  60.                 [3] = function()
  61.                     addm(7, "kni-m-mise")
  62.                     addv(7, "kni-v-proc")
  63.                     addm(7, "kni-m-cetky")
  64.                     adddel(14)
  65.                     planBusy(small, true)
  66.                     addm(1, "kni-m-kramy")
  67.                     planBusy(small, false)
  68.                 end,
  69.             }
  70.         end
  71.     end
  72.  
  73.     -- -------------------------------------------------------------
  74.     local function prog_init_universal()
  75.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  76.  
  77.         universal.co = 0
  78.         universal.kdo = 0
  79.         local treasures = {}
  80.         for i = 0, 2 do
  81.             treasures[i] = getModelsTable()[universal.index + i]
  82.         end
  83.  
  84.         return function()
  85.             if universal.co == 0 then
  86.                 switch(random(10)){
  87.                     [1] = function()
  88.                         universal.co = 1
  89.                     end,
  90.                     [2] = function()
  91.                         universal.co = 8
  92.                     end,
  93.                 }
  94.                 if universal.co ~= 0 then
  95.                     universal.kdo = random(3)
  96.                 end
  97.             elseif isRange(universal.co, 1, 3) then
  98.                 treasures[universal.kdo].afaze = universal.co
  99.                 universal.co = universal.co + 1
  100.             elseif isRange(universal.co, 4, 6) then
  101.                 treasures[universal.kdo].afaze = 7 - universal.co
  102.                 universal.co = universal.co + 1
  103.             elseif isRange(universal.co, 8, 9) then
  104.                 treasures[universal.kdo].afaze = universal.co - 4
  105.                 universal.co = universal.co + 1
  106.             elseif isRange(universal.co, 10, 11) then
  107.                 treasures[universal.kdo].afaze = 15 - universal.co
  108.                 universal.co = universal.co + 1
  109.             else
  110.                 treasures[universal.kdo].afaze = 0
  111.                 universal.co = 0
  112.             end
  113.             treasures[universal.kdo]:updateAnim()
  114.         end
  115.     end
  116.  
  117.     -- -------------------------------------------------------------
  118.     local function prog_init_big()
  119.         return function()
  120.             if big.Y < 18 then
  121.                 room.zakaz = 1
  122.             end
  123.         end
  124.     end
  125.  
  126.     -- -------------------------------------------------------------
  127.     local function prog_init_pc2()
  128.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  129.  
  130.         pc2.stav = 0
  131.  
  132.         return function()
  133.             if pc2.stav > 0 then
  134.                 pc2.stav = pc2.stav - 1
  135.             else
  136.                 pc2.stav = random(300) + 50
  137.             end
  138.             if isRange(pc2.stav, 2, 3) then
  139.                 pc2.afaze = pc2.afaze - 1
  140.             elseif isRange(pc2.stav, 6, 7) then
  141.                 pc2.afaze = pc2.afaze + 1
  142.             elseif pc2.stav == 8 then
  143.                 if random(2) == 1 then
  144.                     pc2.afaze = 0
  145.                 else
  146.                     pc2.afaze = 3
  147.                 end
  148.             end
  149.             pc2:updateAnim()
  150.         end
  151.     end
  152.  
  153.     -- -------------------------------------------------------------
  154.     local function prog_init_switcher()
  155.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  156.     end
  157.  
  158.     -- -------------------------------------------------------------
  159.     local function prog_init_pf2()
  160.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  161.  
  162.         pf2.afaze = random(2)
  163.         pf2:updateAnim()
  164.     end
  165.  
  166.     -- -------------------------------------------------------------
  167.     local function prog_init_db1()
  168.         return function()
  169.             if db1.dir == dir_no then
  170.                 db1.afaze = 0
  171.             else
  172.                 db1.afaze = 1
  173.             end
  174.             db1:updateAnim()
  175.         end
  176.     end
  177.  
  178.     -- -------------------------------------------------------------
  179.     local function prog_init_pf1()
  180.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  181.  
  182.         pf1.afaze = random(2)
  183.         pf1:updateAnim()
  184.     end
  185.  
  186.     -- -------------------------------------------------------------
  187.     local function prog_init_db2()
  188.         return function()
  189.             if db2.dir == dir_no then
  190.                 db2.afaze = 0
  191.             else
  192.                 db2.afaze = 1
  193.             end
  194.             db2:updateAnim()
  195.         end
  196.     end
  197.  
  198.     -- -------------------------------------------------------------
  199.     local function prog_init_pc1()
  200.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  201.  
  202.         pc1.stav = 0
  203.  
  204.         return function()
  205.             if pc1.stav > 0 then
  206.                 pc1.stav = pc1.stav - 1
  207.             else
  208.                 pc1.stav = random(300) + 50
  209.             end
  210.             if isRange(pc1.stav, 2, 3) then
  211.                 pc1.afaze = pc1.afaze - 1
  212.             elseif isRange(pc1.stav, 6, 7) then
  213.                 pc1.afaze = pc1.afaze + 1
  214.             elseif pc1.stav == 8 then
  215.                 if random(2) == 1 then
  216.                     pc1.afaze = 0
  217.                 else
  218.                     pc1.afaze = 3
  219.                 end
  220.             end
  221.             pc1:updateAnim()
  222.         end
  223.     end
  224.  
  225.     -- -------------------------------------------------------------
  226.     local function prog_init_krystal()
  227.         local pom1, pom2, pomb1, pomb2 = 0, 0, false, false
  228.  
  229.         local crystals = {}
  230.         for pom1 = 0, 9 do
  231.             item = getModelsTable()[krystal.index + pom1]
  232.             crystals[pom1] = item
  233.             pom2 = random(7) * 4
  234.             item.afaze = pom2
  235.             item.glob1 = 0
  236.             item.glob2 = pom2
  237.         end
  238.  
  239.         return function()
  240.             for key, item in pairs(crystals) do
  241.                 if item.glob1 == 0 then
  242.                     if random(25) == 1 then
  243.                         item.glob1 = item.glob1 + 1
  244.                     end
  245.                 elseif isRange(item.glob1, 1, 5) then
  246.                     item.glob1 = item.glob1 + 1
  247.                 elseif item.glob1 == 6 then
  248.                     item.glob1 = 0
  249.                 end
  250.                 if isRange(item.glob1, 0, 3) then
  251.                     pom2 = item.glob1
  252.                 elseif isRange(item.glob1, 4, 6) then
  253.                     pom2 = 7 - item.glob1
  254.                 end
  255.                 item.afaze = item.glob2 + pom2
  256.                 item:updateAnim()
  257.             end
  258.         end
  259.     end
  260.  
  261.     -- --------------------
  262.     local update_table = {}
  263.     local subinit
  264.     subinit = prog_init_room()
  265.     if subinit then
  266.         table.insert(update_table, subinit)
  267.     end
  268.     subinit = prog_init_universal()
  269.     if subinit then
  270.         table.insert(update_table, subinit)
  271.     end
  272.     subinit = prog_init_big()
  273.     if subinit then
  274.         table.insert(update_table, subinit)
  275.     end
  276.     subinit = prog_init_pc2()
  277.     if subinit then
  278.         table.insert(update_table, subinit)
  279.     end
  280.     subinit = prog_init_switcher()
  281.     if subinit then
  282.         table.insert(update_table, subinit)
  283.     end
  284.     subinit = prog_init_pf2()
  285.     if subinit then
  286.         table.insert(update_table, subinit)
  287.     end
  288.     subinit = prog_init_db1()
  289.     if subinit then
  290.         table.insert(update_table, subinit)
  291.     end
  292.     subinit = prog_init_pf1()
  293.     if subinit then
  294.         table.insert(update_table, subinit)
  295.     end
  296.     subinit = prog_init_db2()
  297.     if subinit then
  298.         table.insert(update_table, subinit)
  299.     end
  300.     subinit = prog_init_pc1()
  301.     if subinit then
  302.         table.insert(update_table, subinit)
  303.     end
  304.     subinit = prog_init_krystal()
  305.     if subinit then
  306.         table.insert(update_table, subinit)
  307.     end
  308.     return update_table
  309. end
  310. local update_table = prog_init()
  311.  
  312.  
  313. -- -----------------------------------------------------------------
  314. -- Update
  315. -- -----------------------------------------------------------------
  316. function prog_update()
  317.     for key, subupdate in pairs(update_table) do
  318.         subupdate()
  319.     end
  320. end
  321.  
  322.